<template>
  <div>
    <h3>自定义指令自动聚焦</h3>
    <input type="text" v-focus v-model="msg" v-color='color'>
    <button @click="color='green'">改颜色</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: '老韩害怕打雷',
      color: 'red'
    }
  },
  directives: {
    'focus': {
      inserted(el) {
        console.log(el);
        el.focus()
      }
    }
  }
}
</script>

<style>

</style>